import Vue from 'vue';
import Vuex from 'vuex';
import * as auth from '@/utils/auth'

Vue.use(Vuex);

const store = new Vuex.Store ({
    state:  {
        user : auth.getUser()
    },
    mutations: {
        //登录成功后，调用mutation 更新容器中的user状态
        setUser ( state, data) {
            state.user = data 
            auth.setUser(state.user)
        }
    },
    actions : {}
})

export default store